package com.dianjing.dianqun.service.dianpai;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import com.dianjing.dianqun.common.base.CrudService;
import com.dianjing.dianqun.dao.dianpai.DianPaiContentLikeMapper;
import com.dianjing.dianqun.model.DianPaiContentLike;

/**
 * @date : 2017年10月13日
 * 
 * @author: baoyongtao
 * 
 * @see :
 * 
 */

@Service
@Transactional(readOnly = true, isolation = Isolation.DEFAULT)
public class DianPaiContentLikeService extends CrudService<DianPaiContentLikeMapper, DianPaiContentLike> {

	@Autowired
	private DianPaiContentLikeMapper contentLikeMapper;
	
	/**
	 * 根据用户id查询文章点赞
	 * @param userId
	 * @param contentId
	 * @return
	 */
	public DianPaiContentLike selectLikeByUser(Integer userId, Integer contentId) {
		return contentLikeMapper.selectLikeByUser(userId,contentId);
	}

	/**
	 * 取消收藏
	 * @param userId
	 * @param contentId
	 */
	@Transactional(readOnly=false,isolation=Isolation.DEFAULT)
	public void cancelLikeByContentId(Integer userId, Integer contentId) {
		contentLikeMapper.cancelLikeByContentId(userId,contentId);
	}

}
